refactor(hash-aggr): Migrate single mode hash aggregation#23408
refactor(hash-aggr): Migrate single mode hash aggregation#234082010YOUY01 wants to merge 5 commits into
Conversation
alamb
left a comment
There was a problem hiding this comment.
I hope to review this tomorrow
|
run benchmarks |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: clickbench_partitioned File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: tpch File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: tpcds File an issue against this benchmark runner |
alamb
left a comment
There was a problem hiding this comment.
Thank you @2010YOUY01 -- there are a few ignored results that I think are worth looking at, but otherwise this looks ready to go
cc @Rachelint
| let baseline_metrics = BaselineMetrics::new(&agg.metrics, partition); | ||
|
|
||
| // Preserve the existing aggregate metric surface for this plan node. | ||
| let _spill_metrics = SpillMetrics::new(&agg.metrics, partition); |
There was a problem hiding this comment.
This variable is ignored -- why bother to make it? Or is this a TODO when we implement spilling? If so, perhaps we can leave the TODO / link to more context
There was a problem hiding this comment.
Removed in b94c290
BTW now the only remaining work for this refactor is spilling for different aggregation modes
| hash_table: &mut AggregateHashTable<SingleMarker>, | ||
| ) -> Result<()> { | ||
| let input_schema = self.input.schema(); | ||
| self.input = Box::pin(EmptyRecordBatchStream::new(input_schema)); |
There was a problem hiding this comment.
maybe worth a comment that this eagerly releases the input stream
|
|
||
| match result { | ||
| Ok(Some(batch)) => { | ||
| let _ = self |
There was a problem hiding this comment.
I think we should return the error if the reservation fails (rather than ignoring it), right (as is done above in
if let Err(e) = self
.reservation
.try_resize(original_state.hash_table().memory_size())
{
return ControlFlow::Break((
Poll::Ready(Some(Err(e))),
original_state,
));
}|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetpch — base (merge-base)
tpch — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usagetpcds — base (merge-base)
tpcds — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usageclickbench_partitioned — base (merge-base)
clickbench_partitioned — branch
File an issue against this benchmark runner |
|
run benchmark clickbench_partitioned |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing split-aggr-single (ebdd966) to b790763 (merge-base) diff using: clickbench_partitioned File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: CPU Details (lscpu)Details
Resource Usageclickbench_partitioned — base (merge-base)
clickbench_partitioned — branch
File an issue against this benchmark runner |
|
@alamb Thank you for the review. Comments are addressed, and I plan to merge it tomorrow. |
Which issue does this PR close?
Rationale for this change
This PRs implements the single aggregation (fused partial and final aggregation into a single physical plan operator). This mode can be planed if input is already hash/range partitioned.
See comments at datafusion/physical-plan/src/aggregates/single_stream.rs for details.
What changes are included in this PR?
AggregateHashTable<SingleMarker>variant to handle single aggregation.SingleHashAggregateStreamthat usesAggregateHashTable<SingleMarker>to implement the single aggregation state machine.Are these changes tested?
Existing tests for functionalities + UT for planning
Are there any user-facing changes?
No